﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;
using System.Data;

namespace WebSite.cn
{
    public partial class news : System.Web.UI.Page
    {
        // Fields

        public string classname = "新闻中心";
        public string contents = "";


        // Methods
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack && (base.Request.QueryString["tid"] != null))
            {
                DataTable table = SQLAccess.GreatDs("select classname,classcontent from DB_Newsclass where classid=" + base.Request.QueryString["tid"] + "").Tables[0];
                if (table.Rows.Count > 0)
                {
                    this.classname = table.Rows[0][0].ToString();
                    this.contents = table.Rows[0][1].ToString();
                }
            }
        }

        protected void PageChanged(object sender, DataGridPageChangedEventArgs e)
        {
            string str;
            string str2;
            this.productsList.CurrentPageIndex = e.NewPageIndex;
            if (base.Request.QueryString["tid"] != null)
            {
                str2 = re.returnnewstype(base.Request.QueryString["tid"].ToString(), base.Request.QueryString["tid"].ToString(), "1");
                str = "SELECT typeid,newsid,newsname,updatetime FROM DB_News where typeid in(" + str2 + ") and visible=1 and languages=1 order by newsorder,updatetime desc";
            }
            else
            {
                str2 = re.returnnewstype("2", "2", "1");
                str = "SELECT typeid,newsid,newsname,updatetime FROM DB_News where typeid in(" + str2 + ") and visible=1 and languages=1 order by newsorder,updatetime desc";
            }
            DataTable table = new DataTable();
            table = SQLAccess.GreatDs(str).Tables[0];
            if ((table.Rows.Count == 0) && (this.contents != ""))
            {
                this.productsList.Visible = false;
                this.Label1.Text = this.contents;
            }
            else
            {
                this.Label1.Visible = false;
            }
            this.productsList.DataSource = table.DefaultView;
            this.productsList.DataBind();
        }


    }
}